package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements Ioperation{
    @Override
    public void work(BookList bookList) {
        if(bookList.isFull()){
            System.out.println("书架已满，不能添加图书");
            return;
        }
        System.out.println("新增图书.....");
        System.out.println("请输入你要新增图书的书名：");
        Scanner sc=new Scanner(System.in);
        String name= sc.nextLine();
        System.out.println("请输入你要新增图书的作者：");
        String author= sc.nextLine();
        System.out.println("请输入你要新增图书的类型：");
        String type= sc.nextLine();
        System.out.println("请输入你要新增图书的价格：");
        int price= sc.nextInt();

        Book book=new Book(name,author,price,type);
        int currentsize=bookList.getUseSize();
        bookList.setbook(currentsize,book);
        bookList.setUseSize(currentsize+1);
        System.out.println("添加成功.....");

    }
}
